/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package z.h.w.jar.data.time;

import java.sql.Timestamp;
import java.util.Date;
import z.h.w.jar.kit.method.To;

/**
 *
 * @author EnzoZhong
 * @date 2011.10.30
 */
public abstract class AbstractTime extends Timestamp {

      /**
       * 默认构造器
       */
      public AbstractTime () {
            super ( new Date ().getTime () );
      }

      /**
       *
       * @param date
       */
      public AbstractTime ( Date date ) {
            super ( date.getTime () );
      }

      /**
       * 时间构造器
       *
       * @param date
       */
      public AbstractTime ( Long date ) {
            super ( date );
      }

      /**
       * 字符串日期构造器
       *
       * @param date
       */
      public AbstractTime ( String date ) {
            this ( To.string2Date ( date ).getTime () );
      }

      /**
       * 偏移类方法
       *
       * @param multiple
       * @param unit
       *
       * @return
       */
      public abstract Time offset ( Double multiple , Unit unit );

      /**
       * 求时间到目标的差值
       *
       * @param time
       * @param unit
       *
       * @return
       */
      public abstract Double to ( Time time , Unit unit );

      /**
       * 求到时间到现在的差值
       *
       * @param unit
       *
       * @return
       */
      public abstract Double to ( Unit unit );

      /**
       *
       * @param time unit
       * @param unit
       *
       * @return
       */
      public abstract Double to ( String time , Unit unit );

      /**
       *
       * @param find
       * @param regex
       * @param mul
       * @param unit
       *
       * @return
       */
      public abstract Time to ( Attr find , String regex , Double mul , Unit unit );

      /**
       *
       * @param find
       * @param regex
       * @param mul
       * @param unit
       * @param index
       *
       * @return
       */
      public abstract Time to ( Attr find , String regex , Double mul , Unit unit , Integer index );

      /**
       *
       * @param find
       * @param regex
       * @param size
       * @param mul
       * @param unit
       *
       * @return
       */
      public abstract Time[] to ( Attr find , String regex , Integer size , Double mul , Unit unit );

      public abstract Time keep ( Attr attr );

      /**
       * 获取时间信息
       *
       * @param attr
       * @return
       */
      public abstract String tell ( Attr attr );

      public abstract String tellLocale ( Attr attr );

      public abstract String[] tell ( Attr... attr );

      /**
       * 时间前后中关系
       *
       * @param bma
       * @param date
       *
       * @return
       */
      public abstract Boolean is ( Place bma , Date date );

      public abstract Boolean is ( Place bma , Time date );

      public abstract Boolean equals ( Time time , Attr... attrArray );

      public abstract Boolean same ( Attr attr );

      public Date to () {
            return this;
      }

      @Override
      @Deprecated
      public boolean after ( Date when ) {
            return super.after ( when );
      }

      @Override
      @Deprecated
      public boolean before ( Date when ) {
            return super.before ( when );
      }

}
